<template>
  <div class="select-tab">
    <div
      class="meau-item"
      :class="{ activeTab: i === activeIndex }"
      v-for="(item, i) in meauList"
      :key="i"
      @click="switchTab(i)"
    >
      {{ item }}
    </div>
    <div class="btnStyle" v-if="btnShow" @click="changeDialogVisible">
      +添加监控
    </div>
  </div>
</template>

<script>
export default {
  name: "selectTab",
  props: {
    meauList: {
      type: Array,
      default: () => [],
    },
    activeIndex: {
      type: Number,
      default: 0,
    },
    btnShow: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      policyType: "",
      statusText: "",
      type: "",
      dialogVisible: true,
    };
  },
  created() {},
  methods: {
    // 点击菜单
    switchTab(index) {
      //   this.activeIndex = index;
      this.$emit("update:activeIndex", index);
    },
  },
};
</script>

<style lang="scss" scoped>
.select-tab {
  //   width: 100%;
  //   border: 1px solid red;
  //   outline: 1px solid red;
  //height: 100%;
  display: flex;
  align-items: center;
  justify-content: start;
  height: 46px;
  padding-left: 20px;
  font-size: 20px;
  border-bottom: 1px solid #dddddd;
  gap: 60px;
  position: relative;
  font-family: Microsoft YaHei-Regular, Microsoft YaHei;
  // font-weight: bold;
  color: #222222;
  .activeTab.meau-item {
    color: #1c6de2;
    font-weight: bold;
    &::before {
      width: 100%;
      left: 0;
      // right: 0;
    }
  }
  .meau-item {
    position: relative;
    cursor: pointer;
    padding: 0px 6px 10px 6px;
    font-weight: normal;

    // 文字不能被选中
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;

    &::before {
      content: "";
      width: 0;
      height: 3px;
      background-color: #1c6de2;

      border-radius: 2px 2px 2px 2px;
      position: absolute;
      left: 50%;
      bottom: 0px;
      transition: all 0.3s;
    }
    &:hover {
      color: #1c6de2;
      font-weight: bold;
      &::before {
        width: 100%;
        left: 0;
        // right: 0;
      }
      // border-bottom: 4px solid #0171f6;
    }
  }
  .btnStyle {
    width: 110px;
    height: 36px;
    background: #1c6de2;
    border-radius: 4px;
    display: inline-block;
    text-align: center;
    line-height: 36px;
    font-size: 16px;
    color: #fff;
    position: absolute;
    right: 0;
    margin-bottom: 10px;
    cursor: pointer;
  }
}
</style>
